<?php
	include_once '../object/Project.php';
	include_once '../service/Project_Service.php';
        include_once '../service/Gallery_Service.php';

	$project = new Project();
	$service_Project = new Project_Service();
        $service_Gallery = new Gallery_Service();
	if(isset($_POST['btnSubmit']))
	{
                $name       =   $_POST['txtName'];
                $descript   =   $_POST['taDescript'];
		
                $project->setPro_Name($name);
                $project->setPro_Description($descript);
                
                if(isset($_POST['txtCateID']))
                {
                    $cate_id =   $_POST['txtCateID'];
                    $project->setCate_Id($cate_id);
                }
                if(isset($_POST['txtID']))
                {
                    $id =   $_POST['txtID'];
                    $project->setID($id);
                }
	}
	$Action=$_GET['action'];
	//if (isset($_SESSION['login']) && $_SESSION['login'] == 1) {
	if($Action=='insert')
	{
                $service_Project->insert_Project($project);
                echo "<script>window.location='../admin/index.php?action=mp&cate_id=".$cate_id."'</script>";
                
	}
	if($Action=='update')
	{
                $service_Gallery->update_Gallery($id, $descript);
                $service_Project->update_Project($project);
		echo "<script>window.location='../admin/index.php?action=mp&cate_id=".$cate_id."'</script>";
	}
	if($Action=='delete')
	{
                $id =   $_GET['id'];
                $service_Project->delete_Project($id);
                echo "<script>window.location='../admin/index.php?action=mp&cate_id=".$_GET['cate_id']."'</script>";
	}
	//}
?>